<template>
  <div>
    <a-table
      style="height: 40vh;overflow: scroll;"
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :scroll="{x:true}"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
      :loading="loading"
      :rowClassName="tableRowClass"
      @change="handleTableChange">

      <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>

    </a-table>
  </div>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'QisDefectsList',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['unitsn'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: '产品生产历史管理页面',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '产线或产线组',
          align: 'center',
          dataIndex: 'line'
        },
        {
          title: '工站',
          align: 'center',
          dataIndex: 'op'
        },
        {
          title: '主序列号',
          align: 'center',
          dataIndex: 'unitsn'
        },
        {
          title: '从序列类型',
          align: 'center',
          dataIndex: 'idName'
        },
        {
          title: '从序列号值',
          align: 'center',
          dataIndex: 'idValue'
        }
      ],
      url: {
        list: '/trace/barcodeTrace/listMesUnitIdByUnitsn'
      },
      dictOptions: {}
    }
  },
  created() {
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    }
  },
  methods: {
    tableRowClass(record, index) {
      if (record.isOK) {
        return 'red'
      } else {
        return ''
      }
    },

    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

</style>
<style>
.red {
  color: red;
}
</style>